package com.cp.yn.fragment

import android.Manifest
import android.os.Bundle
import android.view.View
import com.common.base.base.BaseFragment
import com.cp.yn.databinding.FragmentHomeBinding
import com.cp.yn.manager.RouterManager
import com.common.base.manager.PermissionManager.reqeustPermission
import com.common.base.tools.arouter.startRouter
import com.common.base.tools.extend.click
import com.common.base.tools.obj.LoadingObj
import com.common.base.tools.utils.logger

/**
 * 三疯
 * *************************
 *
 * *************************
 */
class HomeFragment : BaseFragment<FragmentHomeBinding>() {

    override fun viewBinding(): FragmentHomeBinding {
        return FragmentHomeBinding.inflate(layoutInflater)
    }


    override fun initView(view: View, savedInstanceState: Bundle?) {
        super.initView(view, savedInstanceState)

        viewBinding.scanImg.click {
            permissionRequest()
        }
        viewBinding.qrcode.click {
            LoadingObj.showLoad()
        }


    }


    private fun permissionRequest() {
        val permissList: List<*> = listOf(
            Manifest.permission.CAMERA,
        )
        //请求权限
        reqeustPermission(requireActivity(), permissList as MutableList<String>, {
            startRouter(RouterManager.Path.APP_Scan, callback = { _, data ->
                val qrcode = data?.getStringExtra(RouterManager.Key.APP_Scan_Result)
                logger.info(qrcode)
            })
        }) { list: List<String?>, isNode ->
        }
    }
}